<?php
	
	namespace Aspic\Form\Element;
	
	/**
	* Html input 'text', 'password', 'file' tags extends this class
	*/
	abstract class AbstractInput extends AbstractStandardElement {
		private $inputType;
		
		public function __construct($inputType, $name, $label = '', $value = null, array $options = array(), array $attributes = array()) {
			$this->inputType = $inputType;
			
			parent::__construct($name, $label, $options, $attributes);
			
			if($value !== null) {
				$this->attr('value', $value);
			}
		}
		
		public function getInputType() {
			return $this->inputType;
		}
		
		public function outInput() {
			$out = '<input type="'.$this->getInputType().'"'.$this->getAttrsAndNameStr().'/>';
			
			return $out;
		}
		
		public function bind(array $formData = null)  {
			// Value could be an array when javascript dynamically duplicates the input (so, that could not be managed by the element)
			if(($value = $this->getValue($formData)) AND !is_array($value)) {
				$this->attr('value', $value);
			}
		}

	}	
	
?>